<?php

namespace app\common\model;

use MongoDB\BSON\ObjectId;
use think\Db;
use think\Exception;

/**
 *  客户端表
 */
class Clients extends Base
{

    public static function getGender($key=null)
    {
        $s = [
            0=>'未知',1=>'男',2=>'女'
        ];
        if($key === null){
            return $s;
        }
        return $s[$key];
    }


    public function _where()
    {

        $where = ' 1 ';

        //        $keys = array_merge(input('get.key/a'),input('post.key/a'));

        if (input('get.key/a')) {
            foreach (input('get.key/a') as $k => $v) {
                if (!empty($v)) {
                    switch ($k) {
                        case "date":
                            $applydate = explode("--", $v);
                            $start     = strtotime($applydate[0]);
                            $end       = strtotime($applydate[1]);
                            $where     .= " and '{$start}' <=  unix_timestamp(`create_at`) and '{$end}' >= unix_timestamp(`create_at`) ";
                            break;
                        case "uniqueid":
                            $where     .= " and uniqueid like '%{$v}%'";
                            break;
                        case "tel":
                            $where     .= " and tel like '%{$v}%'";
                            break;
                    }
                }
            }
        }

        return $where;
    }


}
